package com.sky.exceptionApi;

import com.sky.exception.BaseException;
import com.sky.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

/**
 * @BelongsProject: sky-take-out
 * @BelongsPackage: com.sky.context
 * @Author: XieMingHui
 * @CreateTime: 2023-11-17  11:47
 * @Description: TODO
 * @Version: 1.0
 */
//@RestControllerAdvice
@ControllerAdvice
@Slf4j
public class GlobalExceptionHandl {
    @ResponseBody
    @ExceptionHandler(BaseException.class)
    @ResponseStatus(HttpStatus.BAD_REQUEST) // 指定响应状态码
    public Result<String> exceptionHandl(BaseException e){
        String message = e.getMessage();
        e.printStackTrace();
      return Result.error(message);
    }

}
